<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>变化曲线</title>
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <style>
        .outBox{
            width: 100%;
            height: 100%;
        }
        .toolbar{
            height: 72px;
            width: 100%;
            line-height: 72px;
            border: 1px solid #eee;
        }
        .layui-form-label {
            width: 100px;
            line-height: 50px;
        }
    </style>
</head>
<body>
    <div class="outBox">
        <div class="toolbar">
            <div class="layui-form">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">日期范围</label>
                        <div class="layui-inline" id="time">
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" id="startTime" class="layui-input" placeholder="开始日期">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" id="endTime" class="layui-input" placeholder="结束日期">
                        </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['layer', 'laydate'], function () {
        var laydate = layui.laydate,
        layer = layui.layer,
        
        //日期时间选择器
        // laydate.render({
        //     elem: '#time'
        //     ,range: ['#startTime', '#endTime']
        // });
        laydate.render({
            elem: '#startTime',
            format: 'yyyy-MM-dd',
            done: function (value, date, endDate) {
                var startDate = new Date(value).getTime();
                var endTime = new Date($('#endTime').val()).getTime();
                if (endTime < startDate) {
                    layer.msg('结束时间不能小于开始时间');
                    $('#startTime').val('');
                }
            }
        })
        laydate.render({ //结束时间
            elem: '#endTime',
            format: 'yyyy-MM-dd',
            done: function (value, date, endDate) {
                var startDate = new Date($('#startTime').val()).getTime();
                var endTime = new Date(value).getTime();
                if (endTime < startDate) {
                    layer.msg('结束时间不能小于开始时间');
                    $('#endTime').val('');
                }
            }

        })
    })
</script>
</html>